<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Scuola Media E. d'Arborea - Lamarmora </title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="description" content="Il sito della scuola secondaria superiore di Iglesias, in Sardegna" />
<meta name="keywords" content="scuola, iglesias, didattica, insegnamento, docenti" />
<link rel="stylesheet" href="/css/themes/default.css" type="text/css"/>
<link rel="stylesheet" href="/css/themes/mac_os_x.css" type="text/css"/>
<link rel="stylesheet" href="andreas08.css" type="text/css" media="screen,projection" />
<?php include $_ENV["DOCUMENT_ROOT"]."/js/prototype.php" ?>
<script type="text/javascript" src="/js/window.js"></script>
<script type="text/javascript" src="/js/window_effects.js"></script>
<script type="text/javascript" src="/js/page.js"></script>
<script type="text/javascript">
var read = new Array();
var unread = <?php print $_SESSION['__unread_count__'] ?>;
<?php 
reset($circolari_lette);
while (list($k, $v) = each($circolari_lette)){
?>
read[<?php print $k ?>] = <?php print $v ?>;
<?php 
}
?>

function show_text(idc){
	var win = new Window({className: "mac_os_x",  width:400, height:450, zIndex: 100, resizable: true, title: "Testo circolare", showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff, draggable:true, wiredDrag: true});
	win.getContent().update("<div style='margin: auto; text-align: center; padding-bottom: 30px; padding-top: 20px; font-weight: bold' id='obj'></div><div style='margin: auto; text-align: left; padding-left: 200px; padding-bottom: 30px' id='dest'></div><div style='margin: auto; text-align: left; padding-left: 20px; padding-right: 20px; padding-bottom: 20px' id='testo'></div>"); 
	
	var req = new Ajax.Request('/shared/get_circ.php',
			  {
			    	method:'post',
			    	parameters: {idc: idc},
			    	onSuccess: function(transport){
			      		var response = transport.responseText || "no response text";
			      		var dati = response.split("#");
			      		if(dati[0] == "ko"){
							alert("Circolare non presente");
							return;
			      		}
			      		//alert(dati[10]);
			      		$('obj').innerHTML = "Oggetto: "+dati[9];
			      		$('dest').innerHTML = trim(dati[8].replace(/\n/g, "<br />"));
			      		$('testo').innerHTML = dati[10].replace(/\n/g, "<br />");
			    	},
			    	onFailure: function(){ alert("Si e' verificato un errore..."); }
			  });
	win.showCenter(true);
	//alert(read[idc]);
	if(read[idc] == 0)
		unread--;
	read[idc] = 1;
	var mark_read = new Ajax.Request('read_circular.php',
			  {
			    	method:'post',
			    	parameters: {idc: idc},
			    	onSuccess: function(transport){
			      		var response = transport.responseText || "no response text";
			      		//alert(response);
			      		var dati = response.split("#");
			      		if(dati[0] == "ko"){
							alert("Circolare non presente");
							return;
			      		}
			      		
			      		$('l'+idc).style.fontWeight = "normal";
			      		$('n'+idc).style.fontWeight = "normal";
			      		$('p'+idc).style.fontWeight = "normal";
			      		$('d'+idc).style.fontWeight = "normal";
			    	},
			    	onFailure: function(){ alert("Si e' verificato un errore incomprensibile..."); }
			  });
	  //alert(unread);
	  $('num_circ').innerHTML = unread;
}
</script>
</head>
<body>
<div id="container" >
<div id="header">
<h1>Scuola Media E. d'Arborea - Lamarmora</h1>
<h2>area riservata ai docenti</h2>
</div>
<?php include "navigation.php" ?>
<div id="content">
<h2 style="text-align: center">Circolari d'Istituto</h2>
<?php 
     if($result->num_rows < 1){
     ?>
     <div style="margin: auto; padding-top: 20px; font-weight: bold">Non &egrave; presente nessuna circolare</div>
     <div style="margin: auto; padding-top: 20px; font-weight: normal; width: 30%; text-align: right">
     	
     </div>
     <?php 
     }
     else{
     ?>
     <table style="width: 95%; margin-top: 30px">
		<tr style="text-align: center; font-weight: bold">
			<td style="width: 40%; border-bottom: 1px dotted #4b5b75; text-align: left; padding-left: 15px">Oggetto</td>
			<td style="width: 30%; border-bottom: 1px dotted #4b5b75">Data</td>
			<td style="width: 15%; border-bottom: 1px dotted #4b5b75">Numero</td>
			<td style="width: 15%; border-bottom: 1px dotted #4b5b75">Protocollo</td>
		</tr>
	<?php 
		$row = 0;
		$background = "";
     	while ($circolare = $result->fetch_assoc()){
     		$read = 0;
     		if($circolari_lette[$circolare['id_circolare']] == 1)
     			$style = "normal";
     		else
     			$style = "bold";
     		if($row%2)
     			$background = "background-color: #e8eaec";
     		else 
     			$background = "";
     ?>
     	<tr style="text-align: center; font-weight: normal; padding-bottom: 10px">
			<td style="width: 40%; <?php print $background ?>; text-align: left; padding-left: 15px"><a id="l<?php print $circolare['id_circolare'] ?>" href="#" onclick="show_text(<?php print $circolare['id_circolare'] ?>)" style="font-weight: <?php print $style ?>"><?php print utf8_decode($circolare['oggetto']) ?></a></td>
			<td id="d<?php print $circolare['id_circolare'] ?>" style="width: 30%; <?php print $background ?>; font-weight: <?php print $style ?>"><?php print format_date($circolare['data_circolare'], SQL_DATE_STYLE, IT_DATE_STYLE, "/") ?></td>
			<td id="n<?php print $circolare['id_circolare'] ?>" style="width: 15%; <?php print $background ?>; font-weight: <?php print $style ?>"><?php print $circolare['progressivo'] ?></td>
			<td id="p<?php print $circolare['id_circolare'] ?>" style="width: 15%; <?php print $background ?>; font-weight: <?php print $style ?>"><?php print $circolare['protocollo'] ?></td>
		</tr>
     <?php 
     		$row++;
     	}
     ?>
     	
     </table>
     <?php 
     }
     ?>

</div>
<div id="subcontent">
<?php include 'smallbox.php'; ?>
<?php include "working.php" ?>
</div>
<?php include "footer.php" ?>
</div>
</body>
</html>